package com.ruoyi.zsyh.controller;

import java.util.List;

import com.ruoyi.zsyh.domain.ZsyhUserRaker;
import com.ruoyi.zsyh.service.IZsyhUserRakerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单提成人信息Controller
 * 
 * @author yuexl
 * @date 2021-12-21
 */
@Controller
@RequestMapping("/zsyh/raker")
public class ZsyhUserRakerController extends BaseController
{
    private String prefix = "zsyh/raker";

    @Autowired
    private IZsyhUserRakerService zsyhUserRakerService;

    @RequiresPermissions("zsyh:raker:view")
    @GetMapping()
    public String raker()
    {
        return prefix + "/raker";
    }

    /**
     * 查询订单提成人信息列表
     */
    @RequiresPermissions("zsyh:raker:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhUserRaker zsyhUserRaker)
    {
        startPage();
        List<ZsyhUserRaker> list = zsyhUserRakerService.selectZsyhUserRakerList(zsyhUserRaker);
        return getDataTable(list);
    }

    /**
     * 导出订单提成人信息列表
     */
    @RequiresPermissions("zsyh:raker:export")
    @Log(title = "订单提成人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhUserRaker zsyhUserRaker)
    {
        List<ZsyhUserRaker> list = zsyhUserRakerService.selectZsyhUserRakerList(zsyhUserRaker);
        ExcelUtil<ZsyhUserRaker> util = new ExcelUtil<ZsyhUserRaker>(ZsyhUserRaker.class);
        return util.exportExcel(list, "订单提成人信息数据");
    }

    /**
     * 新增订单提成人信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存订单提成人信息
     */
    @RequiresPermissions("zsyh:raker:add")
    @Log(title = "订单提成人信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhUserRaker zsyhUserRaker)
    {
        return toAjax(zsyhUserRakerService.insertZsyhUserRaker(zsyhUserRaker));
    }

    /**
     * 修改订单提成人信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhUserRaker zsyhUserRaker = zsyhUserRakerService.selectZsyhUserRakerById(id);
        mmap.put("zsyhUserRaker", zsyhUserRaker);
        return prefix + "/edit";
    }

    /**
     * 查看订单提成人信息
     */
    @GetMapping("/viewRaker/{id}")
    public String viewRaker(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhUserRaker zsyhUserRaker = zsyhUserRakerService.selectZsyhUserRakerById(id);
        mmap.put("zsyhUserRaker", zsyhUserRaker);
        return prefix + "/viewRaker";
    }

    /**
     * 修改保存订单提成人信息
     */
    @RequiresPermissions("zsyh:raker:edit")
    @Log(title = "订单提成人信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhUserRaker zsyhUserRaker)
    {
        return toAjax(zsyhUserRakerService.updateZsyhUserRaker(zsyhUserRaker));
    }

    /**
     * 删除订单提成人信息
     */
    @RequiresPermissions("zsyh:raker:remove")
    @Log(title = "订单提成人信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhUserRakerService.deleteZsyhUserRakerByIds(ids));
    }
}
